package com.example.zjx8969.myapplication;

import android.app.Application;
import android.util.Log;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;

public class App extends Application {
    public static App app;

    @Override
    public void onCreate() {
        super.onCreate();
//        EventBus.builder().addIndex(new EventBusAppIndex());
        app = this;
        LanguageUtil.checkSetCurLanguage();
        LanguageUtil.checkSetCurCountry(app);
   /*     try {
            long t1 = System.currentTimeMillis();
            Display o = (Display) Class.forName("com.example.zjx8969.myapplication.AppImplement").newInstance();
            Log.e("tag", "factor time:" + (System.currentTimeMillis() - t1));
            o.show();
        } catch (Exception e) {
            e.printStackTrace();
        }
        ServiceLoader<Display> load = ServiceLoader.load(Display.class);
        Iterator<Display> iterator = load.iterator();
        Log.e("tag", iterator.hasNext() + " hasNext");
        while (iterator.hasNext()) {
            iterator.next().show();
        }*/

/*
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll()
                .penaltyLog().build());
        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
*/

/*        Intent intent = new Intent("com.demo.test");
        intent.setPackage(getPackageName());
        startService(intent);*/
        com.facebook.stetho.Stetho.initializeWithDefaults(this);
        OkHttpClient client = new OkHttpClient.Builder()
                .connectTimeout(40, TimeUnit.SECONDS)
                .readTimeout(40, TimeUnit.SECONDS)
                .addNetworkInterceptor(new com.facebook.stetho.okhttp3.StethoInterceptor()).build();
        HttpRequest.setHttpClient(client);

        Log.e("tag", "APP onCreate");
    }


    public static App getInstance() {
        return app;
    }
}
